package dao

import (
	"server/global"
	"server/model"
	"server/utils"
)

func Create(video *model.Video) {
	global.DB.Create(&video)
}

func GetAllVideo(page utils.Pagination) []model.Video {
	var video []model.Video
	global.DB.Select("id,title,icon").Offset(page.Offset()).Limit(page.Limit()).Find(&video)
	return video
}
func GetAllCount() int64 {
	var count int64
	global.DB.Model(&model.Video{}).Count(&count)

	return count
}
func GetVideoDataByUid(uid int32) []model.Video {
	var video []model.Video
	global.DB.Where("user_id  = ?", uid).Where("is_recommend =1 AND status =1").Find(&video)
	return video
}
